#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"

#include "pwm.h"
#include "Key.h"
extern unsigned int num;
unsigned int flag=0;
int main(void)
{
	key_Init();
	Mode_Init_UP();
	OLED_Init();
	while(1)
	{
		Mode_Init_UP();
		Mode_Choice();
		OLED_ShowString(1,1,"Mode:");
		OLED_ShowNum(1,6,num,1);
		if(Key_Fuwei()==1)
		{
			Mode_1();
			OLED_ShowString(2,1,"fu wei");
			num=1;
			OLED_ShowNum(1,6,num,1);
			Delay_s(2);
			OLED_Clear();
		}
		if(Mode_Send()==1)
		{
			if(num==1)
			{
				Mode_1();
				OLED_ShowString(2,1,"Mode1 success");
				Delay_s(2);
				OLED_Clear();
			}
			else if(num==2)
			{
				Mode_2();
				OLED_ShowString(2,1,"Mode2 success");
				Delay_s(2);
				OLED_Clear();
			}
			else if(num==3)
			{
				Mode_3();
				OLED_ShowString(2,1,"Mode3 success");
				Delay_s(2);
				OLED_Clear();
			}
			else if(num==4)
			{
				Mode_4();
				OLED_ShowString(2,1,"Mode4 success");
				Delay_s(2);
				OLED_Clear();
			}
			
		}
		if(Key_Stop()==1)
		{
			Mode_Stop();
			OLED_ShowString(2,1,"Stop");
			while(Key_Start()==0);
		}
		if(Key_Start()==1)
		{
			Mode_Start();
			OLED_ShowString(2,1,"Start");
			Delay_s(2);
		}
	}
}


